有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

无法在xml配置文件的整数属性中解析java Spring EL

我试图在XML配置中使用Spring EL:从现有的beans ConfigProp创建具有队列容量的任务执行器

<task:executor id="executorWithPoolSizeRange" 
               pool-size="#{ConfigProp.async.corePoolSize}-#{ConfigProp.async.maxPoolSize}"
               queue-capacity="#{ConfigProp.async.queueCapacity}"/>

从Intellij的思想来看,它表明pool-size可以正确解析,但对于queue-capacity来说,它不是整数类型

创意投诉信息

Cannot convert string #{ConfigProp.async.queueCapacity} to target class java.lang.Integer"

使用Tomcat运行时的执行日志

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 129 in XML document from ServletContext resource [/WEB-INF/dispatcher-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 129; columnNumber: 69; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'task:executor'.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:402) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]

我做错了什么,或者SpringEL不支持这一点


共 (1) 个答案

  1. # 1 楼答案

    我可以手动创建ThreadPoolTaskExecutorbean,但它仍然不能回答我的问题

    <beans:bean id="executorWithPoolSizeRange" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
            <beans:property name="corePoolSize" value="#{ConfigProp.async.corePoolSize}" />
            <beans:property name="maxPoolSize" value="#{ConfigProp.async.maxPoolSize}" />
            <beans:property name="queueCapacity" value="#{ConfigProp.async.queueCapacity}" />
        </beans:bean>